const express = require('express')

const app = express()

// 回调函数又被称为中间件
// app.get('/api', (req, res) => {
//   res.send('hello world!!!')
// })
  
// 中间件栈
const middlewares = [
  (req, res, next) => {
    console.log(0)
    next()
  },(req, res, next) => {
    console.log(1)
    next()
  }, (req, res, next) => {
    console.log(2)
    next()
    // res.end('2')
  }
]
app.get('/', middlewares)

app.get('/ajax', (req, res, next) => {
  console.log('ajax')
  next()
})

app.get('/api', (req, res) => {
  res.send('hello world')
})

app.listen(8080, () => {
  console.log('localhost:8080')
})

// R(request)MVP(c)
